package com.jiexinyun.service.android.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jiexinyun.dao.JldwMapper;
import com.jiexinyun.dao.KchwtreeGgMapper;
import com.jiexinyun.dao.SysSettingMapper;
import com.jiexinyun.dto.request.androiddict.AndroidGgReq;
import com.jiexinyun.dto.response.AjaxResult;
import com.jiexinyun.entity.JldwEntity;
import com.jiexinyun.entity.KchwtreeGgEntity;
import com.jiexinyun.entity.SysSettingEntity;
import com.jiexinyun.service.android.PublicWorkDictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Slf4j
@Service
public class PublicWorkDictServiceImpl implements PublicWorkDictService {

    @Autowired
    private KchwtreeGgMapper kchwtreeGgMapper;

    @Autowired
    private SysSettingMapper sysSettingMapper;

    @Autowired
    private JldwMapper jldwMapper;

    /**
     * 存货档案规格字段是这么获取的：
     * select gg from kchwtree_gg where pid=@1
     * @1是货物ID 查询的，值和显示列都是 gg,具体各个单据入库规格值也都是用的gg而不是什么规格id字段。
     * @param req
     * @return
     */
    @Override
    public AjaxResult gg(AndroidGgReq req) {

        log.info("存货档案规格查询:{}", req);
        Integer pid = req.getPid();
        LambdaQueryWrapper<KchwtreeGgEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(KchwtreeGgEntity::getPid, pid);
        List<KchwtreeGgEntity> list = kchwtreeGgMapper.selectList(lambdaQueryWrapper);
        return AjaxResult.success(list);
    }

    /**
     * 物料材质查询
     * @return
     */
    @Override
    public AjaxResult wlCz() {

        log.info("存货档案物料材质查询");

        LambdaQueryWrapper<SysSettingEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(SysSettingEntity::getParentid, 107);
        List<SysSettingEntity> list = sysSettingMapper.selectList(lambdaQueryWrapper);

        return AjaxResult.success(list);
    }

    /**
     * 物料标准查询
     * @return
     */
    @Override
    public AjaxResult wlBz() {

        log.info("存货档案物料标准查询");

        LambdaQueryWrapper<SysSettingEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(SysSettingEntity::getParentid, 106);
        List<SysSettingEntity> list = sysSettingMapper.selectList(lambdaQueryWrapper);

        return AjaxResult.success(list);
    }

    /**
     * 物料等级查询
     * @return
     */
    @Override
    public AjaxResult wlDj() {

        log.info("存货档案物料等级查询");

        LambdaQueryWrapper<SysSettingEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(SysSettingEntity::getParentid, 108);
        List<SysSettingEntity> list = sysSettingMapper.selectList(lambdaQueryWrapper);

        return AjaxResult.success(list);
    }

    /**
     * 物料表面处理查询
     * @return
     */
    @Override
    public AjaxResult wlBmcl() {

        log.info("物料表面处理查询");

        LambdaQueryWrapper<SysSettingEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(SysSettingEntity::getParentid, 118);
        List<SysSettingEntity> list = sysSettingMapper.selectList(lambdaQueryWrapper);

        return AjaxResult.success(list);
    }

    /**
     * 计量单位查询
     * @return
     */
    @Override
    public AjaxResult jldw() {

        log.info("计量单位查询");
        LambdaQueryWrapper<JldwEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        List<JldwEntity> list = jldwMapper.selectList(lambdaQueryWrapper);
        return AjaxResult.success(list);
    }

    /**
     * 工艺说明查询
     * @return
     */
//    @Override
//    public AjaxResult jldw() {
//
//        log.info("计量单位查询");
//        LambdaQueryWrapper<WiseJldwEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
//        List<WiseJldwEntity> list = wiseJldwMapper.selectList(lambdaQueryWrapper);
//        return AjaxResult.success(list);
//    }

}
